<?php
$loader->requireOnce('includes/HISFileLoaderException.class.php');
/**
 * Util for loading class.<br>
 * @package local.include
 * @author viethd
 * @version $Id$
 * @copyright 2009 LHV Company
 */
class HISFileLoader  extends FileLoader {
	function __construct() {
		$finder =& new FileFinder();
		$finder->addPath(APP_ROOT.'/local/controllers/');        
		$finder->addPath(APP_ROOT.'/local/includes/');
        $finder->addModulePaths('/local/controllers/');
        $finder->addModulePaths('/local/includes/');        
        $finder->addPath(CELINI_ROOT.'/controllers/');
        parent::FileLoader($finder);
	}
	/**
	 * Load class by given name.
	 * 
	 * The classPath does not contains 'includes'..
	 * EX: includes/utils/ReportUtils.class.php
	 * => classPath is 'utils/ReportUtils' 
	 * 
	 * @param $classPath	 
	 * @Throw HISFileLoaderException if loading fail
	 */	
	public function loadClass($classPath) {
						        
        if ($this->includeOnce($classPath . '.class.php')) {
            return true;
        }
        
        throw new HISFileLoaderException("Class [" . $classPath.'.class.php' . "] not found");
	}
	/**
	 * 
	 * @param $className
	 * @return Object in need
	 * @throws HISFileLoaderException if class is not found
	 */
	public function getObj($classPath) {
		$this->loadClass($classPath);
		$name = split('[/\\]', $classPath);
		$className = $classPath;
		if (count($name) > 0) {
		  $className = $name[count($name) - 1];
		}		
		return new $className();		
	}
	
	
	
}
?>